﻿
@{
    ViewData["Title"] = "List";
}

@section Scripts
    {
    <link href="~/css/page.css" rel="stylesheet" />
    <script src="~/echats/echarts.js"></script>
    <script>
        var selfLayer = null;
        layui.use(['layer', 'table', 'laydate'], function () {
            var layer = layui.layer, form = layui.form, //弹层
                table = layui.table; //表格
            layui.laydate.render({
                elem: '#varRecordTime',
                type: 'year',
                value: '2019'
            })

            picker.GetProvinceList(layui.form, { level: 1 }, "varProvince", {}); //省
            //   picker.GetFishTypeList(layui.form, { type: "鱼种" }, "varFishName", {});  //Province
            form.on("select(Province)", function (data) {
                axios.get('https://fishopeni.cnfm.com.cn:8095/api/Basis/GetAreaAll', {
                    params: {
                        level: 2,
                        code: data.value
                    }
                }).then(function (result) {
                    console.log(result.data.result.data);
                    if (result.data.Code == 200) {
                        var options = '<option value="">请选择市</option>';
                        var resultdata = result.data.result.data;
                        if (resultdata != null) {
                            for (var i = 0; i < resultdata.length; i++) {
                                if (data.value == resultdata[i].yunCode)
                                    options += '<option value="' + resultdata[i].areaName + '" selected>' + resultdata[i].areaName + '</option>';
                                else
                                    options += '<option value="' + resultdata[i].areaName + '">' + resultdata[i].areaName + '</option>';
                            }
                        }
                        if ($("#City"))
                            $("#City").html(options);
                        if ($("#varCity"))
                            $("#varCity").html(options);
                        form.render();
                    } else {
                        alert(response.data.msg)
                    }

                }).catch(function (error) {
                    console.log(error);
                });
            })
            $(function () {
                myEcharts();
            });


        });

        function myEcharts() {

            var parameter = {
                fishType: $("#varFishName option:selected").val(),
                province: $("#varProvince option:selected").val(),
                city: $("#varCity option:selected").val(),
                dateYear: $("#varRecordTime").val(),
            };
            console.log(parameter);
            var myChart = echarts.init(document.getElementById("main"));
            var time = "";
            var timetype = "";
            $.get("/FishSpeciesReport/FishSpeciesYearReport", parameter, function (result) {
                if (result.Code == "200") {
                    myChart.hideLoading();
                    // myChart.setOption(result.result);
                    result.data = JSON.stringify(result.result);

                    var dataX = [];
                    var dataY = [];

                    var thead = "<tr>";
                    var tbody = "<tr>";
                    for (var j = 0; j < result.result.length; j++) {
                        dataX.push(result.result[j].fishName);
                        dataY.push(result.result[j].averagePrice);

                        thead += "<td>" + result.result[j].fishName + "</td>";
                        tbody += "<td><a onclick='oenpage(\"" + result.result[j].fishName + "\")'>" + result.result[j].averagePrice + "</a></td>";
                    }

                    thead += "</tr>";
                    tbody += "/<tr>";


                    console.log(dataX);
                    console.log(dataY);
                    option = {
                        title: {
                            text: '鱼种价格分析',
                            x: 'center',
                            y: 20,
                        },
                        //   color: ['#47F4F6', '#FF4DA4', '#A67EFF', '#FFCD57', '#63E3BB', '#D955FF', '#3D98E5', '#FF8CBF', '#1FCFFF', '#FF9149', '#6CFF9B', '#FFE59F', '#2BECFF', '#D17AFF', '#5489FF', '#7EA5FF', '#72FFE1', '#FF7F87', '#34B3FF', '#FF8F7F'],
                        legend: {
                            textStyle: {
                                fontSize: 16
                            },
                            //x: 'center',
                            //y: -10,
                            //  data: legenddata
                        },
                        tooltip: {
                            trigger: 'axis',
                            textStyle: {//图例文字的样式
                                fontSize: 16
                            }
                        },
                        toolbox: {
                            x: '85%',
                            y: 20,
                            feature: {
                                magicType: {
                                    show: true,
                                    type: ['line', 'bar'],
                                    title: { line: '折线图切换', bar: '柱形图切换' },
                                    iconStyle: {
                                        emphasis: {
                                            textPosition: 'top'
                                        }
                                    }
                                },
                                saveAsImage: {
                                    show: true, title: '下载', iconStyle: {
                                        emphasis: {
                                            textPosition: 'top'
                                        }
                                    }
                                }
                            },
                            textStyle: {//图例文字的样式
                            }
                        },
                        xAxis: {
                            name: '鱼种',
                            axisLabel: {
                                rotate: 60,
                                interval: 0

                            },
                            textStyle: {//图例文字的样式
                                fontSize: 16
                            },

                            data: dataX
                        },
                        yAxis: {
                            type: 'value',
                            name: '',
                            margin: 10,
                            textStyle: {
                            },
                            axisLabel: {
                                interval: 'auto',
                                rotate: -15,
                                margin: 18,
                                formatter: '{value}/元'
                            },
                            axisLine: {    // 轴线
                                show: true,
                                lineStyle: {
                                    type: 'dashed',
                                    width: 1
                                }
                            }
                        },
                        series: [
                            {
                                data: dataY,
                                type: 'bar'
                            }
                        ]
                    };
                    myChart.clear();
                    myChart.setOption(option);
                    $("#thdata").html(thead);
                    $("#tbdata").html(tbody);
                } else {
                    alert(result.msg);
                }

            });
        }

        function oenpage(e) {
            //window.location.href = "/FishSpeciesReport/ListFrom?fishName=" + e + "&dateYear=" + $("#varRecordTime").val() + "&province=" + $("#varProvince option:selected").val() + "&city=" + $("#varCity option:selected").val() + "&unitType=" + $("#varFishType option:selected").val();
            window.location.href = "/FishSpeciesReport/ListFrom?fishName=" + e + "&dateYear=" + $("#varRecordTime").val() + "&province=" + $("#varProvince option:selected").val() + "&city=" + $("#varCity option:selected").val() + "&unitType=0";
        }
    </script>
}

<blockquote class="layui-elem-quote layui-text layui-form">
    <div class="layui-inline">
        <label class="layui-form-label">时间：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="varRecordTime" name="varRecordTime" style="width:240px" placeholder="yyyy-MM-dd">
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">鱼种类别：</label>
        <div class="layui-input-inline">
            <select id="varFishName" name="varFishName" lay-filter="FishName" autocomplete="off">
                <option value="淡水鱼类">淡水鱼类</option>
                <option value="海藻类">海藻类</option>
                <option value="淡水其它类">淡水其它类</option>
                <option value="海水头足类">海水头足类</option>
                <option value="海水鱼类">海水鱼类</option>
                <option value="海水贝类">海水贝类</option>
                <option value="海水甲壳类">海水甲壳类</option>
                <option value="淡水甲壳类">淡水甲壳类</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">省：</label>
        <div class="layui-input-inline">
            <select id="varProvince" name="varProvince" lay-filter="Province" autocomplete="off">
                <option value="">请选择省</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">市：</label>
        <div class="layui-input-inline">
            <select id="varCity" name="varCity" lay-filter="City" autocomplete="off">
                <option value="">请选择市</option>
            </select>
        </div>
    </div>
    <div class="layui-inline" style="width: 120px;">
        <div class="layui-form-label">
            <button class="layui-btn" id="search" style="width: 60px; height: 28px; line-height: 28px; display: inline" onclick="myEcharts()" data-type="reload">搜索</button>
        </div>
    </div>
</blockquote>
<table class="layui-table" id="dataview" lay-filter="datalist">
    <thead id="thdata"> </thead>
    <tbody id="tbdata"></tbody>
</table>

<br />
<div id="main" style="height: 600px; width: 100%; min-width:960px"></div>

